from .consumption_mysql import ConsumPtion
from .conn_mysql import ConnectMysql
from .consumption_notify import ConsumptionNotify
from flask import request

from . import app_particular_authority


#检查用户是否关注对应的用户
@app_particular_authority.route('/particular_authority', methods = ['GET', 'POST', 'PUT', 'DELETE'])

def get_return():

    if request.method == 'GET':

        company_id = request.args.get('company_id')

        consumption_id = request.args.get('consumption_id')

        return ConsumPtion().get_return(company_id, consumption_id)

    return {'status': 1,'errorCod': "0", 'errorMsg': '请检查请求方式', 'resultBody': None}

#用户消费链接接口
@app_particular_authority.route('/add_consumption')

def consumption():

    if request.method == 'GET':

        get_params = request.args

        company_id = get_params.get('company_id')
        consumption_id = get_params.get('consumption_id')

        with ConsumptionNotify(company_id, consumption_id) as CN:

            result = CN.add_consumpation()

        return result

    else:

        return {
            'status': -1,
            'errorCode': 110,
            'errorMsg':'请求方式不是GET',
            'resultBody':None
        }
        


